import javax.swing.JOptionPane;
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;


public class alarmbox {
	
	public static void playAlarm(String message, String sensor) {
		try {
			AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("src/res/alarmsound.wav").getAbsoluteFile());
	        Clip clip = AudioSystem.getClip();
	        clip.open(audioInputStream);
	        clip.start();
	        clip.loop(1000000000);
		}
		catch(Exception ex) {
			System.out.println("Error with playing sound.");
	        ex.printStackTrace();
		}
		JOptionPane.showMessageDialog(null,message,sensor,JOptionPane.WARNING_MESSAGE);
	}
}

